﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;

using ERPStore.Extensions;

namespace ERPStore.Web.Exporter.Controllers
{
	public class ShopzillaApiController : ApiController
	{
		public static object m_Lock = new object();

		public ShopzillaApiController(ERPStore.Services.ICacheService cacheService
			, ERPStore.Exporter.Models.Settings settings
			, ERPStore.Exporter.Services.ShopzillaService shopzillaService
			, ERPStore.Logging.ILogger logger)
		{
			this.CacheService = cacheService;
			this.Settings = settings;
			this.ShopzillaService = shopzillaService;
			this.Logger = logger;
		}

		protected ERPStore.Services.ICacheService CacheService { get; set; }
		protected ERPStore.Exporter.Models.Settings Settings { get; private set; }
		protected ERPStore.Exporter.Services.ShopzillaService ShopzillaService { get; private set; }
		protected ERPStore.Logging.ILogger Logger { get; private set; }

		[System.Web.Http.HttpGet]
		[System.Web.Http.HttpPost]
		public DateTime Ping()
		{
			return DateTime.Now;
		}


		[ERPStore.Web.Controllers.ActionFilters.ApiAuthorizedOperation]
		[System.Web.Http.HttpGet]
		[System.Web.Http.HttpPost]
		public List<ERPStore.Exporter.Models.ShopzillaCategory> GetCategories()
		{
			var result = ShopzillaService.GetCategories();
			return result;
		}

	}
}